<?php

// 设置脚本类型
header('content-type:application/json;charset=UTF-8');

$connect = mysqli_connect('127.0.0.1', 'root', 'root', 'mq2024');
$sql = "SELECT salary.*,staff.name FROM salary join staff on salary.name_id = staff.id where name_id = 22";
$query = mysqli_query($connect, $sql);
$data = mysqli_fetch_all($query);
// print_r($data);
// echo json_encode(['code' => 1, 'msg' => 'success', 'data' => $data]);

//$month = [];
$yData = [];
$xData = [];

foreach ($data as $value) {
    //$month[] = $value['0'];
    array_push($yData, $value['2']);
    array_push($xData, $value['3']);
}
// print_r(json_encode($yData));
echo json_encode(['code' => 1, 'msg' => '查询成功', 'data' => [
    //'month' => $month,
    'salary' => $yData,
    'date' => $xData
]
]);